package cn.yunhe.action;

import java.util.List;

import cn.yunhe.entity.Admin;
import cn.yunhe.serves.AdminServes;

public class AdminAction extends BaseAction {
	private Admin admin ;
	public Admin getAdmin() {
		return admin;
	}
	
	public void setAdmin(Admin admin) {
		this.admin = admin;
	}

	public String adminLogin(){
		AdminServes adminServes = new AdminServes();
		Admin an =adminServes.adminLogin(admin.getAdminname(), admin.getAdminpass());
		if (an!=null) {
			getMapSession().put("adminname", an.getAdminname());
			return SUCCESS;
		}else {
			return ERROR;
		}
	}
	
	public String adminRegist(){
		AdminServes adminServes=new AdminServes();
		boolean flag=adminServes.adminRegist(admin.getAdminname(), admin.getAdminpass());
		if (flag) {
			getMapSession().put("name", admin.getAdminname());
			return SUCCESS;
		}else {
			return ERROR;
		}
	}
	
	public String selectAllAdmin(){
		AdminServes adminServes=new AdminServes();
		List<Admin> list=adminServes.selectAllAdmin();
		if (list!=null) {
			getMapSession().put("list", list);
			return SUCCESS;
		}else {
			return ERROR;
		}
	}
	
	public String deleteAdmin(){
		AdminServes adminServes=new AdminServes();
		boolean flag=adminServes.deleteAdmin(admin.getAdminid());
		if (flag) {
			return SUCCESS;
		}else {
			return ERROR; 
		}
	}

}
